<?php
    require_once ('__common.php');

    list($count) = mysql_fetch_row(mysql_query('SELECT count(1) FROM book'));

    $page = isset($_GET['page'])? $_GET['page'] : 1;
    $offset = ($page-1) * 16;

    $sql = "SELECT * FROM book LIMIT $offset, 16";
    $res = mysql_query($sql); 

    $data = array();
    $i = 0;
    while($temp1 = mysql_fetch_assoc($res)) {
        if($i % 4 == 0 && $i != 0) {
            $data[] = $temp2;
            $temp2 = array();
        }
            $temp1['price'] = number_format($temp1['price']);
            $temp2[] = $temp1;
$i++;
    }
            $data[] = $temp2;
            $temp2 = array();

    $pager  = getPager2($count, 16);
    $tpl->print_('basic');
